#ifndef MAILBOX_H
#define MAILBOX_H

#include <string>
#include <sstream>

#include <Qt\qmessagebox.h>
#include <Qt\qurl.h>
#include <Qt\qdesktopservices.h>

#include "Mail.h"
#include "rapidxml.hpp"

class MailBox{
public :
	static const std::string MBOX_NODE;
	static const std::string MBOX_EMAIL_NODE;
	static const std::string MBOX_REPLYTO_NODE;
	static const std::string MBOX_PROJECT_NAME_NODE;
	static const std::string MBOX_SENDER_NAME_NODE;
	static const std::string MBOX_LOGIN_NODE;
	static const std::string MBOX_PASSWORD_NODE;
	static const std::string MBOX_SERVER_NODE;
	static const std::string MBOX_PORT_NODE;
	static const std::string MBOX_SSL_NODE;
	static const std::string MBOX_DEFAULT_MAIL_CLIENT_NODE;

	static const int MAIL_SENT;
	static const int MAIL_ERROR;

private :
	std::string* mailAddr;
	std::string* replyTo;
	//std::string* senderName;
	std::string* projectName;
	//std::string* login;
	//std::string* password;
	//std::string* server;
	//int port;
	//bool useSSL;

	bool useDefaultMailClient;

	MailBox(const MailBox&){}

public :
	MailBox(void) : mailAddr(0), /*login(0), password(0), server(0), useSSL(false),*/ useDefaultMailClient(true) {}
	
	MailBox(std::string _mailAddr, std::string _replyTo, std::string _projectName, /*std::string _senderName, std::string _login, std::string _password, std::string _server, int _port, bool _useSSL,*/ bool _useDefaultMailClient) {
		mailAddr = new std::string(_mailAddr);
		replyTo = new std::string(_replyTo);
		projectName = new std::string(_projectName);
		//senderName = new std::string(_senderName);
		//login = new std::string(_login);
		//password = new std::string(_password);
		//server = new std::string(_server);
		//port = _port;
		//useSSL = _useSSL;
		useDefaultMailClient = _useDefaultMailClient;
	}

	virtual ~MailBox(void){
		delete(mailAddr);
		delete(replyTo);
		delete(projectName);
		//delete(senderName);
		//delete(login);
		//delete(password);
		//delete(server);
	}

	std::string* getMailAddr(void) const { return mailAddr; }
	std::string* getReplyTo(void) const { return replyTo; }
	std::string* getProjectName(void) const { return projectName; }
	//std::string* getSenderName(void) const { return senderName; }
	//std::string* getLogin(void) const { return login; }
	//std::string* getPassword(void) const { return password; }
	//std::string* getServer(void) const { return server; }
	//int getPort(void) const { return port; }
	//bool isSSLenabled(void) const { return useSSL; }
	bool shouldUseDefaultMailClient(void) const { return useDefaultMailClient; }

	void setMailAddr(std::string _mailAddr) { mailAddr = new std::string(_mailAddr); }
	void setReplyTo(std::string _replyTo) { replyTo = new std::string(_replyTo); }
	void setProjectName(std::string _projectName) { projectName = new std::string(_projectName); }
	//void setSenderName(std::string _senderName) { senderName = new std::string(_senderName); }
	//void setLogin(std::string _login) { login = new std::string(_login); }
	//void setPassword(std::string _password) { password = new std::string(_password); }
	//void setServer(std::string _server) { server = new std::string(_server); }
	//void setPort(int _port) { port = _port; }
	//void enableSSL(bool _enable) { useSSL = _enable; }
	void setUseDefaultMailClient(bool _enable) { useDefaultMailClient = _enable; }

	//bool sendMail(Mail* mail);
	bool sendMailWithDefaultClient(Mail* mail);

	bool isValid(void) const;

	rapidxml::xml_node<>* constructNode(rapidxml::xml_document<>* doc) const;
};

#endif //MAILBOX_H